home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue40 / Alfresco / TstRoman.dpr < prev    next >
Encoding:
Text File  |  1998-10-31  |  1.2 KB  |  57 lines

  1. program TstRoman;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6.   SysUtils, AACvRomn;
  7.  
  8. var
  9.   i, j : integer;
  10.   S : string;
  11. begin
  12.   writeln('Testing to see we can convert to/from Roman and get same value');
  13.   for i := 1 to 3999 do begin
  14.     S := IntToRoman(i);
  15.     j := RomanToInt(S);
  16.     if (i <> j) then begin
  17.       writeln('error: ', i, ' ', S);
  18.       readln;
  19.     end;
  20.   end;
  21.   writeln('...Done');
  22.   writeln('Testing various bad Roman numbers');
  23.   try
  24.     S := 'MCMDCCM';
  25.     i := RomanToInt(S);
  26.     writeln('error: shouldn''t get ', i, ' with "', S, '"');
  27.   except
  28.     on E: EConvertError do
  29.       writeln(E.Message);
  30.   end;
  31.   try
  32.     S := 'MCCCC';
  33.     i := RomanToInt(S);
  34.     writeln('error: shouldn''t get ', i, ' with "', S, '"');
  35.   except
  36.     on E: EConvertError do
  37.       writeln(E.Message);
  38.   end;
  39.   try
  40.     S := 'MVV';
  41.     i := RomanToInt(S);
  42.     writeln('error: shouldn''t get ', i, ' with "', S, '"');
  43.   except
  44.     on E: EConvertError do
  45.       writeln(E.Message);
  46.   end;
  47.   try
  48.     S := 'IXV';
  49.     i := RomanToInt(S);
  50.     writeln('error: shouldn''t get ', i, ' with "', S, '"');
  51.   except
  52.     on E: EConvertError do
  53.       writeln(E.Message);
  54.   end;
  55.   readln;
  56. end.
  57.